<template>
    <div class="course-item" v-loading="isLoading">
        <div>
            <el-image :src="require('../images/catalogue-title.png')" style="height: 28px;"></el-image>
        </div>
        <el-collapse v-model="activeNames" class="directory">
            <el-collapse-item :name="index" v-for="item, index in directoryList" :key="index">
                <template slot="title" class="directory-title">
                    <h3>{{ item.title }}</h3>
                </template>
                <div class="directory-child-item" v-for="citem, cindex in item.childList" :key="cindex">
                    <div>
                        <i class="el-icon-video-camera-solid"></i>
                        <span>视频：{{ citem.title }}</span>
                    </div>
                    <div>
                        <span>{{ citem.time }}</span>
                    </div>
                </div>
            </el-collapse-item>

        </el-collapse>
    </div>
</template>

<script>
import { reqCouerseDirectory } from "@/api/course"
export default {
    name: "course-detail-directory",
    data() {
        return {
            directoryList: [],
            isLoading: false,
        }
    },
    methods: {
        getCouerseDirectory() {
            const courseId = this.$route.params.courseId;
            this.isLoading = true;
            reqCouerseDirectory({
                courseId: courseId,
            }).then((res) => {
                this.directoryList = res.data;
                this.isLoading = false;
            }).catch((error) => {
                this.isLoading = false;
                this.$message.error(error.message)
            })
        }
    },
}
</script>

<style scoped>
.course-item {
    margin-top: 20px;
}

.directory {
    margin: 20px 0;
}

.directory-child-item {
    cursor: pointer;
    padding: 10px 0px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.directory-child-item i {
    font-size: 18px;
    margin-right: 5px;
}

.directory-child-item:hover{
    background-color: rgb(250, 248, 248);
}
</style>